package com.leet.code.simple_array;

/**
 * @description:    1491.去掉最低工资和最高工资后的工资平均值
 * @author: WYG
 * @time: 2021/1/5 9:35
 */

public class Average {
    public double average(int[] salary) {
        int max = 0;
        int min = 1000000;
        int sum = 0;
        for (int i = 0; i < salary.length; i++) {
            if (salary[i] > max) {
                max = salary[i];
            }
            if (salary[i] < min) {
                min = salary[i];
            }
            sum += salary[i];
        }
        return (sum - max - min + 0.0) / (salary.length - 2);
    }
}
